package fy.uap.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.apache.commons.logging.LogFactory;

import fy.config.FyConfig;
import fy.util.DBUtil;


public class AcceptanceDao {
	private static org.apache.commons.logging.Log log = LogFactory
			.getLog(AcceptanceDao.class);

	/**
	 * 插入计算机及周边设备验收单的数据
	 * @param content 数据
	 * @return
	 */
	public boolean insert(String[] content) {
		boolean success = false;
		Connection conn = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		try {
			conn = DBUtil.connect(FyConfig.getUAP_DB_CONFIG());


			pst = conn
					.prepareStatement("insert into eam_asset_it_i  (PK_ASSET_IT_I, PK_CORP, C_DATE, OA_NUMBER, ASSETCODE, FY_CODE, ASSETNAME, ACCEPT_DATE, WARRANTY, ASSET_MODEL, MANUFACTURER, SERIALNUMBER, SERVICE_NO, CONFIG, MONITOR_SN, MOUSE_SN, KEYBOARD_SN, BATTERY_SN, POWERADAPTER_SN, MAC, WIRELESS_MAC,ATTRNAME1,attrname2,pk_deptdoc,using_user) select substr(sys_guid(),0,20),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,a.* from (select p.dept,u.cuserid from v_fyperf_psndoc p left join sm_user u on p.staff_id = u.user_code where p.staff_id = ? and u.dr = 0 group by p.dept,u.cuserid) a ");

			for (int i = 0; i < content.length; i++) {
				pst.setString(i + 1, content[i]);
			}
			pst.execute();

			success = true;

		} catch (Exception e) {
			e.printStackTrace();
			log.error("插入计算机及周边设备验收单的数据发生异常", e);
		} finally {
			DBUtil.close(rs, pst, conn);
		}
		return success;
	}
}
